package com.jinsi.controller.yrf;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jinsi.constant.YrfConstant;
import com.jinsi.pojo.SyLoginLog;
import com.jinsi.service.yrf.AdministratorLoginLogService;
import com.jinsi.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 * @author: 86185
 * @description: 管理员登录日志以及前台用户登陆日志
 * @date 2022/9/7
 */
@RestController
@RequestMapping("/administratorLoginLog")
public class AdministratorLoginLogController {

    @Autowired
    private AdministratorLoginLogService administratorLoginLogService;

    /**
     * 获取后台管理员登陆日志所有数据(模糊查询)
     * @param logLoginAccount 模糊查
     * @param logLoginName 模糊查
     */

    @RequestMapping("/getAll")
    public R getAll(Integer page, Integer limit, String logLoginAccount, String logLoginName){

        PageHelper.startPage(page,limit);
        List<SyLoginLog> all = administratorLoginLogService.getAll(logLoginAccount,logLoginName);

        PageInfo<SyLoginLog> pageInfo = new PageInfo<>(all);
        return R.custom(YrfConstant.LAYUI_CODE,
                YrfConstant.LAYUI_MSG,
                pageInfo.getList(),
                pageInfo.getTotal());

    }

    /**
     *
     *获取前台用户登陆日志所有数据(模糊查询)
     * @param logLoginAccount 模糊查
     * @param logLoginName 模糊查
     */
    @RequestMapping("/usergetAll")
    public R usergetAll(Integer page, Integer limit, String logLoginAccount,String logLoginName){

        PageHelper.startPage(page,limit);
        List<SyLoginLog> all = administratorLoginLogService.usergetAll(logLoginAccount,logLoginName);

        PageInfo<SyLoginLog> pageInfo = new PageInfo<>(all);

        return R.custom(YrfConstant.LAYUI_CODE,
                YrfConstant.LAYUI_MSG,
                pageInfo.getList(),
                pageInfo.getTotal());

    }

    /**
     *删除登录日志行(两个通用)
     * @param loginLogId 根据loginLogId删除
     */
    @RequestMapping("/del")
    public R administratorLoginLogdelete(int loginLogId){
        administratorLoginLogService.administratorLoginLogdelete(loginLogId);
        return R.ok("成功");
    }


}
